import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.TreeSet;

public class HJ41 {
    /**
     * 输入
     *      2
     *      1   2
     *      2   1
     * 输出
     *      5
     */
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String s = reader.readLine();
        Integer total = Integer.valueOf(s);
        String s1 = reader.readLine();
        String[] weight = s1.split(" ");
        int[] weights = new int[total];
        for (int i = 0; i < weights.length; i++) {
            weights[i] = Integer.valueOf(weight[i]);
        }
        String s2 = reader.readLine();
        String[] number = s2.split(" ");
        int[] numbers = new int[total];
        for (int i = 0; i < numbers.length; i++) {
            numbers[i] = Integer.valueOf(number[i]);
        }
        HashSet<Integer> set = new HashSet<>();
        set.add(0);
        for (Integer i = 0; i < total; i++) {
            ArrayList<Integer> list = new ArrayList<>(set);
            for (int j = 1; j <= numbers[i]; j++) {
                for (int k = 0; k < list.size(); k++) {
                    set.add(list.get(k)+weights[i]*j);
                }
            }
        }
        System.out.println(set.size());
    }
}
